﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DoveyAttribute.ValidateExtend
{
    /// <summary>
    /// 高度的限制
    /// </summary>
    [AttributeUsage( AttributeTargets.Field| AttributeTargets.Property)]
     public class HeightAttribute: AbstractValidateAttribute
    {
        public long _Max { get; set; }
        public long _Min { get; set; }

        public HeightAttribute(long max,long min)
        {
            this._Min = min;
            this._Max = max;
        }
        public override bool Validate(object value)
        {
            if(value ==null)
            {
                return false;
            }
            
            long.TryParse(value.ToString(),out long LValue);
            if(LValue>_Max&& LValue < _Min)
            {
                return false;
            }
            return true;

        }

        //public override bool Validate(object obj)
        //{
        //    throw new NotImplementedException();
        //}
    }
}
